﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEE.Model
{
    public class PileCal: PileBase
    {
        EPileType ePCType;
        eDB N1, N2, N3, N4, N5, N6, N7;
        int numN1, numN2, numN3;
        int spaceN4, spaceN5, spaceN6;
        double Length;      // 总桩长，从cut off level，mm为单位
        int Cover = 75;

        int DiaPile = 1000; // 桩径
        //声明与内加强筋有关的参数变量
        int PhiTop, PhiMitUp, PhiMitLo, PhiBot; //外径
        int LenTop, LenMitUp, LenMitLo, LenBot; //长度
        int NumTopRing, NumMitUpRing, NumMitLoRing, NumBotRing; //长度

        int LapLength = 300;    // 搭接长度
        int ringSpace = 2000;   // 加强筋间距

        int FirstTieLen = 6500; // 第一段6.5m加密区域
        int SecTieLen = 8000;   // 第二段8m加密区域

        public PileCal(EPileType _ePCType, string typeName, string pierNumber, eSubType subType, double pileLength,int dia, int dowel)
            : base(typeName, pierNumber, subType, pileLength, dia)
        {
            Length = pileLength;
            ePCType = _ePCType;
            DowelLen = dowel;
            DiaPile = dia;
            if (dia == 1000)
            {
                switch (ePCType)
                {
                    case EPileType.None:
                        return;
                    case EPileType.Type1:
                        N1 = eDB.DB20;
                        numN1 = 20;
                        N2 = eDB.DB20;
                        //numN2 = 10;
                        numN2 = 14;//修改
                        N3 = eDB.DB20;
                        numN3 = 8;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB16;
                        spaceN4 = 200;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type2:
                        N1 = eDB.DB20;
                        numN1 = 20;
                        N2 = eDB.DB20;
                        numN2 = 14;
                        N3 = eDB.DB20;
                        numN3 = 8;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB16;
                        spaceN4 = 200;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type3:
                        N1 = eDB.DB25;
                        numN1 = 20;
                        N2 = eDB.DB20;
                        numN2 = 16;
                        N3 = eDB.DB20;
                        numN3 = 10;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB20;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type4:
                        N1 = eDB.DB28;
                        numN1 = 26;
                        N2 = eDB.DB25;
                        numN2 = 16;
                        N3 = eDB.DB20;
                        numN3 = 10;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB20;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type5:
                        N1 = eDB.DB32;
                        numN1 = 30;
                        N2 = eDB.DB25;
                        numN2 = 24;
                        N3 = eDB.DB20;
                        numN3 = 14;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        break;
                    case EPileType.Type6:
                        N1 = eDB.DB32;
                        numN1 = 36;
                        N2 = eDB.DB25;
                        numN2 = 24;
                        N3 = eDB.DB20;
                        numN3 = 14;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        break;
                    case EPileType.Type7:
                        N1 = eDB.DB32;
                        numN1 = 40;
                        N2 = eDB.DB25;
                        numN2 = 28;
                        N3 = eDB.DB20;
                        numN3 = 14;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        break;
                    case EPileType.Type1T:
                        N1 = eDB.DB25;
                        numN1 = 28;
                        N2 = eDB.DB25;
                        numN2 = 28;
                        N3 = eDB.DB25;
                        numN3 = 28;
                        N4 = eDB.DB16;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 250;
                        spaceN6 = 500;
                        break;
                }
            }
            else
            {
                switch (ePCType)
                {
                    case EPileType.None:
                        return;
                    case EPileType.Type1:
                        N1 = eDB.DB20;
                        numN1 = 13;
                        N2 = eDB.DB16;
                        //numN2 = 10;
                        numN2 = 14;//修改
                        N3 = eDB.DB16;
                        numN3 = 8;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB16;
                        spaceN4 = 200;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type2:
                        N1 = eDB.DB25;
                        numN1 = 10;
                        N2 = eDB.DB20;
                        numN2 = 10;
                        N3 = eDB.DB16;
                        numN3 = 8;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB20;
                        spaceN4 = 200;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type3:
                        N1 = eDB.DB25;
                        numN1 = 16;
                        N2 = eDB.DB20;
                        numN2 = 16;
                        N3 = eDB.DB16;
                        numN3 = 12;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB20;
                        spaceN4 = 200;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type4:
                        N1 = eDB.DB32;
                        numN1 = 18;
                        N2 = eDB.DB25;
                        numN2 = 18;
                        N3 = eDB.DB20;
                        numN3 = 12;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        SecTieLen = (int)(Length * 1000) / 3 - FirstTieLen;
                        break;
                    case EPileType.Type5:
                        N1 = eDB.DB32;
                        numN1 = 28;
                        N2 = eDB.DB25;
                        numN2 = 22;
                        N3 = eDB.DB20;
                        numN3 = 12;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        break;
                    case EPileType.Type6:
                        N1 = eDB.DB32;
                        numN1 = 34;
                        N2 = eDB.DB25;
                        numN2 = 26;
                        N3 = eDB.DB20;
                        numN3 = 14;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        break;
                    case EPileType.Type7:
                        N1 = eDB.DB32;
                        numN1 = 40;
                        N2 = eDB.DB25;
                        numN2 = 30;
                        N3 = eDB.DB20;
                        numN3 = 14;
                        N4 = eDB.DB12;
                        N5 = eDB.DB12;
                        N6 = eDB.DB12;
                        N7 = eDB.DB25;
                        spaceN4 = 150;
                        spaceN5 = 300;
                        spaceN6 = 500;
                        break;
                }
            }
        }

        public override void SetRebarList()//根据excel来
        {

            int mainLen = 12000;   // 主筋长度,12m
            double labN1N2 = GlobalFuncs.transmit10Num(GlobalFuncs.GetLapLength(eConcreteClass.C30, N2) * 1.7 / 1.3) * 0.001;
            double labN2N3 = GlobalFuncs.transmit10Num(GlobalFuncs.GetLapLength(eConcreteClass.C30, N3) * 1.7 / 1.3) * 0.001;
            int Len1b = FirstTieLen + (int)DowelLen;
            int Len2b = SecTieLen + FirstTieLen + (int)DowelLen - mainLen + (int)(labN1N2 * 1000);
            int num = (int)(Length * 1000 + DowelLen - 75 + labN1N2 * 1000 - mainLen) / mainLen;
            int Len = (int)(Length * 1000 + DowelLen - 75 - (num + 1) * mainLen + labN1N2 * 1000 + labN2N3 * 1000 * num);
            //if (Len > 12000 - labN2N3 * 1000)
            //    num = num + 1;
            if (Len > 12000)
                num = num + 1;
            int Len3b = (int)(Length * 1000 + DowelLen - 75 - (num + 1) * mainLen + labN1N2 * 1000 + labN2N3 * 1000 * num);

            RebarList = new RebarCollection();
            if (numN1 - numN2 != 0)
            {
                RebarList.Add(new MPIRebarRecord(1, 0, "a", N1, mainLen, numN2, eShapeType.PileB, "Bottom Lapping=" + labN1N2.ToString("0.000") + "m"));    //1a 12m通长
                RebarList.Add(new MPIRebarRecord(1, 0, "b", N1, Len1b, numN1 - numN2, eShapeType.Pile));
            }
            else
            {
                RebarList.Add(new MPIRebarRecord(1, 0, "", N1, mainLen, numN1, eShapeType.PileB, "Bottom Lapping=" + labN1N2.ToString("0.000") + "m"));    //1a 12m通长
            }
            RebarList.Add(new MPIRebarRecord(2, 0, "a", N2, mainLen, numN3, eShapeType.PileBT, "Top Lapping=" + labN1N2.ToString("0.000") + "m", "Bottom Lapping=" + labN2N3.ToString("0.000") + "m"));    //1a 12m通长
            if (Len2b > 12 * 1000)
            {
                int Len2c = Len2b - mainLen + (int)(labN1N2 * 1000);
                if (Len2c > 12 * 1000)
                {

                }
                else
                {
                    if (numN2 - numN3 > 0)
                    {
                        RebarList.Add(new MPIRebarRecord(2, 0, "b", N2, mainLen, numN2 - numN3, eShapeType.PileBT, "Top Lapping=" + labN1N2.ToString("0.000") + "m", "Bottom Lapping=" + labN1N2.ToString("0.000") + "m"));    //1a 12m通长
                        RebarList.Add(new MPIRebarRecord(2, 0, "c", N2, Len2c, numN2 - numN3, eShapeType.PileT, "Top Lapping=" + labN1N2 + "m"));
                    }
                }
            }
            else
            {
                if (numN2 - numN3 > 0)
                    RebarList.Add(new MPIRebarRecord(2, 0, "b", N2, Len2b, numN2 - numN3, eShapeType.PileT, "Top Lapping=" + labN1N2 + "m"));
            }
            RebarList.Add(new MPIRebarRecord(3, 0, "a", N3, mainLen, numN3, eShapeType.PileBT, "Top Lapping=" + labN2N3.ToString("0.000") + "m", "Bottom Lapping=" + labN2N3.ToString("0.000") + "m"));    //1a 12m通长
            if (num == 3)
            {
                RebarList.Add(new MPIRebarRecord(3, 0, "b", N3, mainLen, numN3, eShapeType.PileBT, "Top Lapping=" + labN2N3.ToString("0.000") + "m", "Bottom Lapping=" + labN2N3.ToString("0.000") + "m"));
                RebarList.Add(new MPIRebarRecord(3, 0, "c", N3, Len3b, numN3, eShapeType.PileT, "Top Lapping=" + labN2N3.ToString("0.000") + "m"));
            }
            else if (num > 3)
            {
                if (num == 3)
                    RebarList.Add(new MPIRebarRecord(3, 0, "b", N3, mainLen, numN3, eShapeType.PileT, "Top Lapping=" + labN2N3.ToString("0.000") + "m"));
                else
                {
                    for (int i = 1; i < num - 1; i++)
                    {
                        RebarList.Add(new MPIRebarRecord(3, i, "b", N3, mainLen, numN3, eShapeType.PileBT, "Top Lapping=" + labN2N3.ToString("0.000") + "m", "Bottom Lapping=" + labN2N3.ToString("0.000") + "m"));
                    }
                }
                RebarList.Add(new MPIRebarRecord(3, 0, "c", N3, Len3b, numN3, eShapeType.PileT, "Top Lapping=" + labN2N3.ToString("0.000") + "m"));
            }
            else
            {
                RebarList.Add(new MPIRebarRecord(3, 0, "b", N3, Len3b, numN3, eShapeType.PileT, "Top Lapping=" + labN2N3.ToString("0.000") + "m"));
            }

            double pileD = (DiaPile - 2 * Cover) * 0.001;
            #region N4
            double L4 = (FirstTieLen - Cover) * 0.001 * GlobalFuncs.GetSpiralLength(FirstTieLen - Cover, Convert.ToInt32(N4), spaceN4, DiaPile);

            double Hook4 = GlobalFuncs.GetHookLength(N4, 135) * 0.001;
            L4 += (DiaPile - 2 * Cover - Convert.ToInt32(N4)) * 0.001 * 1.5 * Math.PI + (Hook4) * 2;
            double Lap4 = GlobalFuncs.GetLapLength(eConcreteClass.C30, N4) * 0.001;
            //4a
            int Len4a = 12;
            RebarList.Add(new MPZRebarRecord(4, 0, "a", N4, Len4a * 1000, 1, eShapeType.PileMZB, pileD, "1-Lapping+hook=" + (Lap4 + Hook4)));
            //4b
            int Len4b = 12;
            double Lap4b = GlobalFuncs.GetLapLength(eConcreteClass.C30, N4) * 0.001;
            double Hook4b = GlobalFuncs.GetHookLength(N4, 135) * 0.001;
            int Num4b = (int)((L4 - Len4a) / (Len4b - 2 * Hook4b - Lap4b)); ;
            RebarList.Add(new MPZRebarRecord(4, 0, "b", N4, Len4b * 1000, Num4b, eShapeType.PileMZBT, pileD, "2-Lapping+hook=" + (Lap4b + Hook4b)));
            //4c
            double Lap4c = GlobalFuncs.GetLapLength(eConcreteClass.C30, N5) * 0.001;
            double Hook4c = GlobalFuncs.GetHookLength(N5, 135) * 0.001;
            double Len4c = L4 - (Len4a - Lap4b - 2 * Hook4) * 1 - (Len4b - Lap4b - 2 * Hook4b) * Num4b + 0.04;
            if (N4 == N5)
                RebarList.Add(new MPZRebarRecord(4, 0, "c", N4, (int)(Len4c * 1000), 1, eShapeType.PileMZBT, pileD, "2-Lapping+hook=" + (Lap4c + Hook4c)));
            else
                RebarList.Add(new MPZRebarRecord(4, 0, "c", N4, (int)(Len4c * 1000), 1, eShapeType.PileMZBT, pileD, "1-Lapping+hook=" + (Lap4b + Hook4b), "1-Lapping+hook=" + (Lap4c + Hook4c)));
            #endregion

            #region N5


            double L5 = (SecTieLen) * 0.001 * GlobalFuncs.GetSpiralLength(SecTieLen, Convert.ToInt32(N5), spaceN5, DiaPile);
            double Lap5 = GlobalFuncs.GetLapLength(eConcreteClass.C30, N5) * 0.001;
            double Hook5 = GlobalFuncs.GetHookLength(N5, 135) * 0.001;
            L5 += (Hook5) * 2 + Lap5;

            //5a
            int Len5a = 12;
            RebarList.Add(new MPZRebarRecord(5, 0, "a", N5, Len5a * 1000, 1, eShapeType.PileMZBTM, pileD, "2-Lapping+hook=" + (Lap5 + Hook5)));
            //5b
            int Len5b = 12;

            double Hook5b = GlobalFuncs.GetHookLength(N5, 135) * 0.001;
            int Num5b = (int)((L5 - Len5a) / (Len5b - 2 * Hook5b - Lap5));
            RebarList.Add(new MPZRebarRecord(5, 0, "b", N5, Len5b * 1000, Num5b, eShapeType.PileMZBTM, pileD, "2-Lapping+hook=" + (Lap5 + Hook5)));
            //5c
            double Lap5c = GlobalFuncs.GetLapLength(eConcreteClass.C30, N6) * 0.001;
            double Hook5c = GlobalFuncs.GetHookLength(N6, 135) * 0.001;
            double Len5c = (L5 - (Len5a - 2 * Hook5 - Lap5) * 1 - (Len5b - 2 * Hook5 - Lap5) * Num5b) * 1000;
            if (N5 == N6)
                RebarList.Add(new MPZRebarRecord(5, 0, "c", N5, (int)Len5c, 1, eShapeType.PileMZBTM, pileD, "2-Lapping+hook=" + (Lap5 + Hook5)));
            else
                RebarList.Add(new MPZRebarRecord(5, 0, "c", N5, (int)Len5c, 1, eShapeType.PileMZBTM, pileD, "1-Lapping+hook=" + (Lap5 + Hook5), "1-Lapping+hook=" + (Lap5c + Hook5c)));
            #endregion

            #region N6
            double l6 = Length * 1000 - FirstTieLen - SecTieLen;
            double L6 = (l6 - Cover) * 0.001 * GlobalFuncs.GetSpiralLength(l6 - Cover, Convert.ToInt32(N6), spaceN6, DiaPile);
            double Lap6 = GlobalFuncs.GetLapLength(eConcreteClass.C30, N6) * 0.001;
            double Hook6 = GlobalFuncs.GetHookLength(N6, 135) * 0.001;
            L6 += (DiaPile - 2 * Cover - Convert.ToInt32(N6)) * 0.001 * 1.5 * Math.PI + (Hook6) * 2 + Lap6;

            //6a
            int Len6a = 12;
            RebarList.Add(new MPZRebarRecord(6, 0, "a", N6, Len6a * 1000, 1, eShapeType.PileMZBTB, pileD, "2-Lapping+hook=" + (Lap6 + Hook6)));
            //6b
            int Len6b = 12;
            double Lap6b = GlobalFuncs.GetLapLength(eConcreteClass.C30, N6) * 0.001;
            double Hook6b = GlobalFuncs.GetHookLength(N6, 135) * 0.001;
            int Num6b = (int)((L6 - Len6a) / (Len6b - 2 * Hook6b - Lap6b));
            RebarList.Add(new MPZRebarRecord(6, 0, "b", N6, Len6b * 1000, Num6b, eShapeType.PileMZBTB, pileD, "2-Lapping+hook=" + (Lap6 + Hook6)));
            //6c
            double Lap6c = GlobalFuncs.GetLapLength(eConcreteClass.C30, N6) * 0.001;
            double Len6c = (L6 - (Len6a - 2 * Hook6 - Lap6) * 1 - (Len6b - 2 * Hook6 - Lap6) * Num6b) * 1000;
            //double Len6c = (L6 - Num6b * (Len6b - 2 * Hook6b - Lap6b) - Len6a + 2 * Hook6b + Lap6b + Lap6c) * 1000;
            RebarList.Add(new MPZRebarRecord(6, 0, "c", N6, (int)Len6c, 1, eShapeType.PileMZTB, pileD, "1-Lapping+hook=" + (Lap6 + Hook6)));
            #endregion


            #region 加强筋部分  N7
            // 首层加强筋外径 : 桩基直径 - 2*保护层-2*外螺旋筋直径 - 2*主筋直径
            PhiTop = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N1) - 2 * Convert.ToInt32(N4);   //对应7a
            PhiMitUp = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N1) - 2 * Convert.ToInt32(N5); //对应7b
            PhiMitLo = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N2) - 2 * Convert.ToInt32(N5); //对应7c
            PhiBot = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N3) - 2 * Convert.ToInt32(N6);   //对应7d
            //计算对应加强筋的总长度 : (外径 - 自身直径)
            LenTop = (int)Math.Round((PhiTop - Convert.ToInt32(N7)) * Math.PI + LapLength, 3, MidpointRounding.AwayFromZero);
            LenMitUp = (int)Math.Round((PhiMitUp - Convert.ToInt32(N7)) * Math.PI + LapLength, 3, MidpointRounding.AwayFromZero);
            LenMitLo = (int)Math.Round((PhiMitLo - Convert.ToInt32(N7)) * Math.PI + LapLength, 3, MidpointRounding.AwayFromZero);
            LenBot = (int)Math.Round((PhiBot - Convert.ToInt32(N7)) * Math.PI + LapLength, 3, MidpointRounding.AwayFromZero);
            //计算对应加强筋的数量
            NumTopRing = (int)Math.Ceiling((double)(FirstTieLen + labN1N2 * 1000 - Cover) / ringSpace);
            NumMitUpRing = (int)Math.Ceiling((double)(mainLen - labN1N2 * 1000 - DowelLen - 6500) / ringSpace);
            NumMitLoRing = (int)Math.Ceiling((double)(mainLen - labN1N2 * 1000) / ringSpace);
            //NumBotRing = (int)Math.Ceiling((double)(Length * 1000 - 2 * mainLen + (labN1N2 + labN2N3) * 1000) / ringSpace);
                    
            NumBotRing = (int)Math.Ceiling((double)(Length * 1000) / ringSpace) - NumTopRing - NumMitUpRing - NumMitLoRing;
            //NumMitLoRing = (int)Math.Round((double)(mainLen - labN1N2 * 1000) / ringSpace, 1, MidpointRounding.ToEven); 
            //NumBotRing = (int)Math.Round((double)(Length * 1000) / ringSpace, 1, MidpointRounding.ToEven) - NumTopRing - NumMitUpRing - NumMitLoRing;

            //NumTopRing = (int)Math.Round((double)(FirstTieLen + labN1N2 * 1000 - Cover) / ringSpace, 1, MidpointRounding.ToEven);
            //NumMitUpRing = (int)Math.Round((double)(mainLen - labN1N2 * 1000 - DowelLen - 6500) / ringSpace, 1, MidpointRounding.ToEven) + 1;
            //NumMitLoRing = (int)Math.Round((double)(mainLen - labN1N2 * 1000) / ringSpace, 1, MidpointRounding.ToEven);
            //NumBotRing = (int)Math.Round((double)(Length * 1000 - 2 * mainLen + (labN1N2 + labN2N3) * 1000) / ringSpace, 1, MidpointRounding.ToEven) + 1;

            if (N1 == N2&&N2==N3)
            {
                if (N4 == N5&&N5==N6)
                {

                    //NumTopRing = (int)Math.Ceiling((double)(Length * 1000) / ringSpace);
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "", N7, LenTop, LapLength, PhiTop, NumTopRing + NumMitLoRing + NumMitUpRing+ NumBotRing, eShapeType.PileC));  //7b 加强筋
                }
                else if (N4 == N5)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing + NumMitLoRing + NumMitUpRing, eShapeType.PileC));  //7b 加强筋              
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));  //7b 加强筋
                }
                else if (N5 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing , eShapeType.PileC));  //7b 加强筋              
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumBotRing + NumMitLoRing + NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                }
                else if (N4 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing + NumBotRing , eShapeType.PileC));  //7b 加强筋              
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitLoRing + NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                }
                else
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing , eShapeType.PileC));  //7b 加强筋              
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitLoRing + NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
            }
            else if (N1 == N2)
            {
                if (N4 == N5)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing + NumMitLoRing + NumMitUpRing, eShapeType.PileC));  //7b 加强筋              
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));  //7b 加强筋
                }
                else
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing , eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing+ NumMitLoRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
            }
            else if (N2 == N3)
            {
                if (N5 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing+ NumBotRing, eShapeType.PileC));  //7c 加强筋
                }
                else
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing, eShapeType.PileC));  //7c 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "d", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
            }
            else if (N1 == N3)
            {
                //PhiTop = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N1) - 2 * Convert.ToInt32(N4);   //对应7a
                //PhiMitUp = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N1) - 2 * Convert.ToInt32(N5); //对应7b
                //PhiMitLo = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N2) - 2 * Convert.ToInt32(N5); //对应7c
                //PhiBot = DiaPile - 2 * Cover - 2 * Convert.ToInt32(N3) - 2 * Convert.ToInt32(N6);   //对应7d
                if (N4 == N5&&N5 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing+ NumMitUpRing +NumBotRing, eShapeType.PileC));  //7b 加强筋
                    //RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing , eShapeType.PileC));  //7c 加强筋
                }
                else if (N5 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing + NumBotRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing, eShapeType.PileC));  //7c 加强筋
                }
                else if (N4 == N6)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing + NumBotRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing , eShapeType.PileC));  //7c 加强筋
                }
                else
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing, eShapeType.PileC));  //7c 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "d", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
            }
            else
            {
                if (N4 == N5)
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing+ NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing, eShapeType.PileC));  //7c 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
                else
                {
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "a", N7, LenTop, LapLength, PhiTop, NumTopRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "b", N7, LenMitUp, LapLength, PhiMitUp, NumMitUpRing, eShapeType.PileC));  //7b 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "c", N7, LenMitLo, LapLength, PhiMitLo, NumMitLoRing, eShapeType.PileC));  //7c 加强筋
                    RebarList.Add(new MYWithFormulaRebarRecord(7, 0, "d", N7, LenBot, LapLength, PhiBot, NumBotRing, eShapeType.PileC));        //7d 加强筋
                }
            }
           

            #endregion

            #region Cover Block
            //
            numCB = (int)(Math.Round(Length / 3, 0, MidpointRounding.AwayFromZero) * 4);
            #endregion
            #region U-bolt          
            //UAN1N2 = numN2 * 4;
            //UAN2N3 = numN3 * 3;
            //UAN3N3 = numN3 * 3;
            //UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
            //UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
            //UBN3N7 = numN3 * NumBotRing;

            if (N1 == N2 && N2 == N3)
            {
                if (N2 == N7)
                {
                    UAN1N2 = numN2 * 4 + numN3 * 3 + numN3 * 3 + (numN1 * NumTopRing + numN2 * NumMitUpRing) + (numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3)+ numN3 * NumBotRing;
                }
                else
                {
                    UAN1N2 = numN2 * 4 + numN3 * 3 + numN3 * 3;
                    UBN1N7 = (numN1 * NumTopRing + numN2 * NumMitUpRing) + (numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3) + numN3 * NumBotRing;
                }
            }
            else if (N1 == N2)
            {
                if(N2==N7)
                {
                    UAN1N2 = numN2 * 4+ (numN1 * NumTopRing + numN2 * NumMitUpRing) + (numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3);
                    UAN3N3 = numN3 * 3;
                    UBN3N7 = numN3 * NumBotRing;
                }
                else if (N3 == N7)
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3 + (numN1 * NumTopRing + numN2 * NumMitUpRing) + (numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3);

                    UAN3N3 = numN3 * 3+ numN3 * NumBotRing;
                    //UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
                    //UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    //UBN3N7 = numN3 * NumBotRing;
                }
                else 
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3;
                    UAN3N3 = numN3 * 3;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing  + (numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3);
                    //UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    UBN3N7 = numN3 * NumBotRing;
                }
               
            }
            else if (N2 == N3)
            {
                if (N3 == N7)
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3 + numN3 * 3 +(numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3)+ numN3 * NumBotRing;
                    //UAN3N3 = numN3 * 3;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
                    //UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    //UBN3N7 = numN3 * NumBotRing;
                }
                else
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3+ numN3 * 3;
                    //UAN3N3 = numN3 * 3;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
                    UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3 + numN3 * NumBotRing;
                    //UBN3N7 = numN3 * NumBotRing;
                }
            }
            else if (N1 == N3)
            {

                 if (N3 == N7)
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3+ numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    UAN3N3 = numN3 * 3+ numN1 * NumTopRing + numN2 * NumMitUpRing + numN3 * NumBotRing;
                
                    //UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    //UBN3N7 = numN3 * NumBotRing;
                }
                else
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3;
                    UAN3N3 = numN3 * 3;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing+ numN3 * NumBotRing;
                    UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                   
                }
            }
            else
            {
                if (N3 == N7)
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3;
                    UAN3N3 = numN3 * 3+ numN3 * NumBotRing;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
                    UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    //UBN3N7 = numN3 * NumBotRing;
                }
                else
                {
                    UAN1N2 = numN2 * 4;
                    UAN2N3 = numN3 * 3;
                    UAN3N3 = numN3 * 3;
                    UBN1N7 = numN1 * NumTopRing + numN2 * NumMitUpRing;
                    UBN2N7 = numN2 * NumMitUpRing + (NumMitLoRing - 2) * numN3;
                    UBN3N7 = numN3 * NumBotRing;
                }
            }

            #endregion
        }

    }
}
